﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DynaPrecision.LinearSystem
{
	public class ArrayWrapper<TWrappedArray, TFrom, TTo> : IMultiDimensionalArray<TTo>
		where TWrappedArray : IMultiDimensionalArray<TFrom>
	{
		public TWrappedArray WrappedArray { get; set; }
		public Func<TFrom, int[], TTo> Selector { get; set; }
		public ArrayWrapper()
		{
		}
		public ArrayWrapper(TWrappedArray array, Func<TFrom, int[], TTo> selector)
		{
			this.WrappedArray = array;
			this.Selector = selector;
		}

		#region IMultiDimensionalArray<TTo> Members

		public TTo this[params int[] index]
		{
			get
			{
				return Selector(WrappedArray[index], index);
			}
			set
			{
				throw new NotImplementedException();
			}
		}

		public int GetLength(int DimensinNumber)
		{
			return this.WrappedArray.GetLength(DimensinNumber);
		}

		public int Dimension
		{
			get { return this.WrappedArray.Dimension; }
		}

		#endregion
	}
}
